package com.mzkj.wanjulaile.mobile.api.modules.address.entity;

import com.mzkj.wanjulaile.mobile.api.common.entity.DataEntity;
import com.mzkj.wanjulaile.mobile.api.modules.account.entity.Account;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotNull;

/**
 * 地址管理Entity
 *
 * @author ianly
 * @version 2016-10-12
 */
public class Address extends DataEntity<Address> {

    private static final long serialVersionUID = 1L;
    private String accountId;        // 用户id
    private String realName;        // 收货人真名
    private String phone;        // 收货人电话
    private Long provinceId;        // 省份id
    private String provinceName;        // 省份名称
    private Long cityId;        // 城市id
    private String cityName;        // 城市名称
    private Long areaId;        // 区id
    private String areaName;        // 区名称
    private String detailAddress;        // 详细地址
    private Integer asDefault;        // 是否默认地址 0否 1是
    private Account account;

    /**
     * 展示使用
     */
    private String region;

    public String getRegion() {
        if (provinceName == null || cityName == null || areaName == null || detailAddress == null) {
            return "";
        }
        region = provinceName + " " + cityName + " " + areaName + " " + detailAddress;
        return region;
    }

    // 省市区
    private String pcaNames;

    public String getPcaNames() {
        return (provinceName == null ? " " : provinceName) + " " + (cityName == null ? " " : cityName) + " " + (areaName == null ? " " : areaName) + " " + detailAddress;
    }

    public void setPcaNames(String pcaNames) {
        this.pcaNames = pcaNames;
    }

    public Address() {
        super();
    }

    public Address(String id) {
        super(id);
    }

    public String getAccountId() {
        return accountId;
    }

    public void setAccountId(String accountId) {
        this.accountId = accountId;
    }

    @Length(min = 1, max = 255, message = "收货人真名长度必须介于 1 和 255 之间")
    public String getRealName() {
        return realName;
    }

    public void setRealName(String realName) {
        this.realName = realName;
    }

    @Length(min = 1, max = 255, message = "收货人电话长度必须介于 1 和 255 之间")
    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public Long getProvinceId() {
        return provinceId;
    }

    public void setProvinceId(Long provinceId) {
        this.provinceId = provinceId;
    }

    public String getProvinceName() {
        return provinceName;
    }

    public void setProvinceName(String provinceName) {
        this.provinceName = provinceName;
    }

    public Long getCityId() {
        return cityId;
    }

    public void setCityId(Long cityId) {
        this.cityId = cityId;
    }

    public String getCityName() {
        return cityName;
    }

    public void setCityName(String cityName) {
        this.cityName = cityName;
    }

    public Long getAreaId() {
        return areaId;
    }

    public void setAreaId(Long areaId) {
        this.areaId = areaId;
    }

    public String getAreaName() {
        return areaName;
    }

    public void setAreaName(String areaName) {
        this.areaName = areaName;
    }

    @Length(min = 1, max = 255, message = "详细地址长度必须介于 1 和 255 之间")
    public String getDetailAddress() {
        return detailAddress;
    }

    public void setDetailAddress(String detailAddress) {
        this.detailAddress = detailAddress;
    }

    @NotNull(message = "是否默认地址 0否 1是不能为空")
    public Integer getAsDefault() {
        return asDefault;
    }

    public void setAsDefault(Integer asDefault) {
        this.asDefault = asDefault;
    }

    public Account getAccount() {
        return account;
    }

    public void setAccount(Account account) {
        this.account = account;
    }
}